package com.hbnu.exercise.File;

import java.io.*;

public class Demo03
{
    public static void main(String[] args)
    {
        String path = "E:" + File.separator + "demo.txt";
        File file = new File(path);
        OutputStream outputStream = null;
        try
        {
            outputStream = new FileOutputStream(file);
            String content = "湖北师范大学计算机与信息工程学院计算机科学与技术2210班";
            byte[] bytes = content.getBytes();
            outputStream.write(bytes);
        }
        catch (IOException e)
        {
            System.out.println("文件写入异常");
        }
        finally
        {
            try
            {
                if (outputStream != null)
                    outputStream.close();
            } catch (IOException e)
            {
                System.out.println("文件关闭异常");
            }
        }
    }
}
